<template>
  <div class="app-container">
    <el-form  class="formWidth" :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
          <el-form-item label="岗位名称" prop="jobName">
            <el-input
              v-model="queryParams.jobName"
              placeholder="请输入岗位名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="岗位类别" prop="jobType">
            <el-select v-model="queryParams.jobType" placeholder="请选择岗位类别" clearable size="small">
              <el-option
                v-for="dict in jobTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="学历要求" prop="education">
            <el-select v-model="queryParams.education" placeholder="请选择学历要求" clearable size="small">
              <el-option
                v-for="dict in educationOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="招聘人数" prop="jobCnt">
            <el-input
              v-model="queryParams.jobCnt"
              placeholder="请输入招聘人数"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item> -->
          <el-form-item label="期望薪资" prop="salaryMax">
            <el-input
              v-model="queryParams.salaryMax"
              placeholder="请输入期望薪资"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <!-- <el-form-item label="薪资类型" prop="salaryType">
            <el-select v-model="queryParams.salaryType" placeholder="请选择薪资类型" clearable size="small">
              <el-option
                v-for="dict in salaryTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item> -->
          <!-- <el-form-item label="岗位是否公开" prop="isPublic" label-width="120px">
            <el-select v-model="queryParams.isPublic" placeholder="请选择岗位是否公开" clearable size="small">
              <el-option
                v-for="dict in isPublicOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item> -->
          <!-- <el-form-item label="是否招聘残疾人" prop="isDisabledAccepted" label-width="120px">
            <el-select v-model="queryParams.isDisabledAccepted" placeholder="请选择是否招聘残疾人" clearable size="small">
              <el-option
                v-for="dict in isDisabledAcceptedOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item> -->
          <el-form-item label="所在省" prop="province">
            <el-select v-model="queryParams.provinceId" filterable clearable @change="queryhandlePChange" placeholder="请选择省" size="small">
                <el-option
                  v-for="dict in provinceOptions"
                  :key="dict.code"
                  :label="dict.name"
                  :value="parseInt(dict.code)"
                ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="所在市" prop="city">
            <el-select v-model="queryParams.cityId" filterable clearable @change="queryhandleCityChange" placeholder="请选择城市" size="small">
                <el-option
                  v-for="dict in querycityOptions"
                  :key="dict.code"
                  :label="dict.name"
                  :value="parseInt(dict.code)"
                ></el-option>
              </el-select>
          </el-form-item>
          <!-- <el-form-item label="所在区" prop="county">
            <el-select v-model="queryParams.countyId" filterable clearable placeholder="请选择区县">
                <el-option
                  v-for="dict in querycountyOptions"
                  :key="dict.code"
                  :label="dict.name"
                  :value="parseInt(dict.code)"
                ></el-option>
              </el-select>
          </el-form-item> -->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['enterprise:position:add']"
        >新增岗位信息</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['enterprise:position:edit']"
        >岗位信息修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['enterprise:position:remove']"
        >岗位信息删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['enterprise:position:export']"
        >岗位信息导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="positionList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="岗位ID" align="center" prop="jobId" /> -->
      <el-table-column label="公司名称" show-overflow-tooltip align="center" prop="companyName" />
      <el-table-column label="岗位名称" show-overflow-tooltip align="center" prop="jobName" />
      <!-- <el-table-column label="岗位类别" align="center" prop="jobType" :formatter="jobTypeFormat" /> -->
      <el-table-column label="岗位类别" show-overflow-tooltip align="center" prop="jobType" :formatter="jobTypeFormat" />
      <el-table-column label="学历要求" show-overflow-tooltip align="center" prop="education" :formatter="educationFormat" />
      <el-table-column label="招聘人数" show-overflow-tooltip align="center" prop="jobCnt" />
      <el-table-column label="最低薪资" show-overflow-tooltip align="center" prop="salaryMin" />
      <el-table-column label="最高薪资" show-overflow-tooltip align="center" prop="salaryMax" />
      <!-- <el-table-column label="薪资类型" align="center" prop="salaryType" :formatter="salaryTypeFormat" /> -->
      
      <!-- <el-table-column label="是否招聘残疾人" align="center" prop="isDisabledAccepted" :formatter="isDisabledAcceptedFormat" /> -->
      <!-- <el-table-column label="省" align="center" prop="provinceName" />
      <el-table-column label="城市" align="center" prop="cityName" /> -->
      <!-- <el-table-column label="区县" align="center" prop="countyName" /> -->
      <!-- <el-table-column label="工作详细地址" align="center" prop="workingAddress" /> -->
      <el-table-column label="联系人" show-overflow-tooltip align="center" prop="contact" />
      <el-table-column label="联系人电话" show-overflow-tooltip align="center" prop="contactPhoneNo" />
      <!-- <el-table-column label="岗位是否公开" align="center" prop="isPublic" :formatter="isPublicFormat" /> -->
      <!-- <el-table-column label="岗位描述" align="center" prop="jobDesc" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="140%">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleDetails(scope.row)"
          >查看详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['enterprise:position:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['enterprise:position:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  <!-- 添加或修改企业岗位信息对话框 -->
  <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px" size="mini">
        <div>
            <span>| </span><span>岗位信息</span>
            <el-divider></el-divider>
        </div>
        <div style="width: 60%;margin:0 auto">
          <!-- <el-form-item label="公司id" prop="companyId">
            <el-input v-model="form.companyId" placeholder="请输入公司id"/>
          </el-form-item> -->
          <el-form-item label="公司名称" prop="companyId">
            <el-select v-model="form.companyId" placeholder="请选择公司">
              <el-option
                v-for="dict in companyOptions"
                :key="dict.companyId"
                :label="dict.companyName"
                :value="parseInt(dict.companyId)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="岗位名称" prop="jobName">
            <el-input style="width:193px" v-model="form.jobName" placeholder="请输入岗位名称" />
          </el-form-item>
          <el-form-item label="岗位类别" prop="jobType">
            <el-select v-model="form.jobType" placeholder="请选择岗位类别">
              <el-option
                v-for="dict in jobTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="parseInt(dict.dictValue)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="学历要求" prop="education">
            <el-select v-model="form.education" placeholder="请选择学历要求">
              <el-option
                v-for="dict in educationOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="parseInt(dict.dictValue)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="招聘人数" prop="jobCnt">
            <!-- <el-input v-model="form.jobCnt" placeholder="请输入招聘人数" /> -->
            <el-input-number v-model="form.jobCnt" :min="1" :max="500" label="请输入招聘人数"></el-input-number>
            <!-- <el-input-number v-model="num" @change="handleChange" :min="1" :max="10" label="描述文字"></el-input-number> -->
          </el-form-item>
          <el-form-item label="薪资类型" prop="salaryType">
            <el-select v-model="form.salaryType" placeholder="请选择薪资类型">
              <el-option
                v-for="dict in salaryTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="parseInt(dict.dictValue)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="薪资范围" prop="salary">
            <el-col :span="10">
              <el-input v-model="form.salaryMin" placeholder="最少薪资" style="width: 90%;"/>
            </el-col>
            <el-col :span="2">至</el-col>
            <el-col :span="10">
              <el-input v-model="form.salaryMax" placeholder="最高薪资" style="width: 90%;"/>
            </el-col>
            元
          </el-form-item>
        </div>
        <div>
            <span>| </span><span>办公地址</span>
            <el-divider></el-divider>
        </div>
        <div style="width: 70%;margin:0 auto">
          <el-form-item label="所在省市区" prop="area">
            <el-col :span="7">
              <el-select v-model="form.provinceId" filterable clearable @change="handlePChange" placeholder="请选择省">
                <el-option
                  v-for="dict in provinceOptions"
                  :key="dict.code"
                  :label="dict.name"
                  :value="parseInt(dict.code)"
                ></el-option>
              </el-select>
            </el-col>
            <el-col :span="1" style="display:inline-block;text-align:center;"><span >-</span></el-col>
            <el-col :span="7">
              <el-select v-model="form.cityId" filterable clearable @change="handleCityChange" placeholder="请选择城市">
                <el-option
                  v-for="dict in cityOptions"
                  :key="dict.code"
                  :label="dict.name"
                  :value="parseInt(dict.code)"
                ></el-option>
              </el-select>
            </el-col>
            <el-col :span="1" style="display:inline-block;text-align:center;"><span>-</span></el-col>
            <el-col :span="7">
              <el-select v-model="form.countyId" filterable clearable placeholder="请选择区县">
                <el-option
                  v-for="dict in countyOptions"
                  :key="dict.code"
                  :label="dict.name"
                  :value="parseInt(dict.code)"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="工作详细地址" prop="workingAddress">
            <el-input v-model="form.workingAddress" placeholder="请输入工作详细地址" />
          </el-form-item> 
        </div>
        <div>
            <span>| </span><span>联系方式</span>
            <el-divider></el-divider>
        </div>
        <div style="width: 60%;margin:0 auto">
          <el-form-item label="联系人" prop="contact">
            <el-input v-model="form.contact" placeholder="请输入联系人" />
          </el-form-item>
          <el-form-item label="联系人电话" prop="contactPhoneNo">
            <el-input v-model="form.contactPhoneNo" placeholder="请输入联系人电话" />
          </el-form-item>
        </div>
        <div>
            <span>| </span><span>岗位描述</span>
            <el-divider></el-divider>
        </div>
        <div style="width: 60%;margin:0 auto">
          <el-form-item label="岗位是否公开" prop="isPublic">
            <el-select v-model="form.isPublic" placeholder="请选择岗位是否公开">
              <el-option
                v-for="dict in isPublicOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="parseInt(dict.dictValue)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否招聘残疾人" prop="isDisabledAccepted">
            <el-select v-model="form.isDisabledAccepted" placeholder="请选择是否招聘残疾人">
              <el-option
                v-for="dict in isDisabledAcceptedOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="parseInt(dict.dictValue)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="岗位描述" prop="jobDesc">
            <el-input v-model="form.jobDesc" type="textarea" placeholder="请输入内容" />
          </el-form-item>
        </div>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改企业岗位信息对话框 -->
  <el-dialog :title="titleDtls" :visible.sync="openDtls" width="800px" append-to-body>
      <div class="containerDtls">
        <el-row :gutter="20">
          <div >
              <span>| </span><span>岗位信息</span>
              <el-divider></el-divider>
          </div>
        </el-row>
        <el-row>
          <div style="width: 60%;margin:0 auto">
            <el-col :span="12" class="cel">
            <span class="label">
              公司名称：
            </span>
            <el-tooltip class="item" effect="dark" :content="jobDtls.companyName" placement="top">
              <span class="value companyName">
                {{jobDtls.companyName}}
              </span>
            </el-tooltip>
            </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                岗位名称：
              </span>
              <span class="value">
                {{jobDtls.jobName}}
              </span>
            </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                岗位类别：
              </span>
              <span class="value" :formatter="jobTypeFormat">
                {{jobDtls.jobType}}
              </span>
            </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                学历要求：
              </span>
              <span class="value" :formatter="educationFormat">
                {{jobDtls.education}}
              </span>
             </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                招聘人数：
              </span>
              <span class="value">
                {{jobDtls.jobCnt}}
              </span>
            </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                最低薪资：
              </span>
              <span class="value">
                {{jobDtls.salaryMin}}
              </span>
            </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                最高薪资：
              </span>
              <span class="value">
                {{jobDtls.salaryMax}}
              </span>
            </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                薪资类型：
              </span>
              <span class="value" :formatter="salaryTypeFormat">
                {{jobDtls.salaryType}}
              </span>
            </el-col>
          </div>
        </el-row>
        <el-row :gutter="20">
          <div style="margin-top:20px">
              <span>| </span><span>办公地址</span>
              <el-divider></el-divider>
          </div>
        </el-row>
        <el-row>
          <div style="width: 80%;margin:0 auto">
            <el-col :span="8" class="cel">
              <span class="label">
                省：
              </span>
              <span class="value">
                {{jobDtls.provinceName}}
              </span>
            </el-col>
            <el-col :span="8" class="cel">
              <span class="label">
                城市：
              </span>
              <span class="value">
                {{jobDtls.cityName}}
              </span>
            </el-col>
            <el-col :span="8" class="cel">
              <span class="label">
                区县：
              </span>
              <span class="value">
                {{jobDtls.countyName}}
              </span>
            </el-col>
            <el-col :span="24" class="cel">
              <span class="label">
                工作详细地址：
              </span>
              <span class="value">
                {{jobDtls.workingAddress}}
              </span>
            </el-col>
          </div>
        </el-row>
        <el-row :gutter="20">
          <div style="margin-top:20px">
              <span>| </span><span>联系方式</span>
              <el-divider></el-divider>
          </div>
        </el-row>
        <el-row>
          <div style="width: 60%;margin:0 auto">
            <el-col :span="12" class="cel">
            <span class="label">
              联系人：
            </span>
            <span class="value">
              {{jobDtls.contact}}
            </span>
            </el-col>
            <el-col :span="12" class="cel">
              <span class="label">
                联系人电话：
              </span>
              <span class="value">
                {{jobDtls.contactPhoneNo}}
              </span>
            </el-col>
          </div>
          </el-row>
            <el-row :gutter="20">
              <div style="margin-top:20px">
                  <span>| </span><span>岗位描述</span>
                  <el-divider></el-divider>
              </div>
            </el-row>
          <el-row>
            <div style="width: 60%;margin:0 auto">
              <el-col :span="12" class="cel">
                <span class="label">
                  岗位是否公开：
                </span>
                <span class="value" :formatter="isPublicFormat">
                  {{jobDtls.isPublic}}
                </span>
              </el-col>
              <el-col :span="12" class="cel">
                <span class="label">
                  是否招聘残疾人：
                </span>
                <span class="value" :formatter="isDisabledAcceptedFormat">
                  {{jobDtls.isDisabledAccepted}}
                </span>
              </el-col>
              <el-col :span="24" class="cel">
                <span class="label">
                  岗位描述：
                </span>
                <span class="value">
                  {{jobDtls.jobDesc}}
                </span>
              </el-col>
            </div>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancelDtls">确 定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listPosition, getPosition, delPosition, addPosition, updatePosition, exportPosition,getJobInfoByCompanyId } from "@/api/enterprise/position";
import { getAllCompanysInfo,provinceList,cityList } from "@/api/jobservice/company";

export default {
  name: "Position",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 企业岗位信息表格数据
      positionList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 弹出层标题
      titleDtls: "",
      // 是否显示弹出层
      openDtls: false,
      // 岗位类别字典
      jobTypeOptions: [],
      // 薪资类型字典
      salaryTypeOptions: [],
      // 学历要求字典
      educationOptions: [],
      // 是否招聘残疾人字典
      isDisabledAcceptedOptions: [],
      // 岗位是否公开字典
      isPublicOptions: [],
      //所有省信息
      provinceOptions:[],
      //所有市信息
      cityOptions:[],
      //所有区域信息
      countyOptions:[],
      //所有市信息 查询条件
      querycityOptions:[],
      //所有区域信息 查询条件
      querycountyOptions:[],
      // 公司列表
      companyOptions:[],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        jobName: null,
        jobType: null,
        jobCnt: null,
        salaryMin: null,
        salaryMax: null,
        salaryType: null,
        education: null,
        isDisabledAccepted: null,
        provinceId: null,
        cityId: null,
        countyId: null,
        workingAddress: null,
        contact: null,
        contactPhoneNo: null,
        isPublic: null,
        jobDesc: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        companyId: [
          { required: true, message: "公司名称不能为空", trigger: "blur" }
        ],
        jobName: [
          { required: true, message: "岗位名称不能为空", trigger: "blur" }
        ],
        jobType: [
          { required: true, message: "岗位类别不能为空", trigger: "change" }
        ],
        jobCnt: [
          { required: true, message: "招聘人数不能为空", trigger: "blur" }
        ],
        salaryType: [
          { required: true, message: "薪资类型不能为空", trigger: "change" }
        ],
        education: [
          { required: true, message: "学历要求不能为空", trigger: "change" }
        ],
        isDisabledAccepted: [
          { required: true, message: "是否招聘残疾人不能为空", trigger: "change" }
        ],
        isPublic: [
          { required: true, message: "岗位是否公开不能为空", trigger: "change" }
        ],
      },
      jobDtls:{}
    };
  },
  created() {
    this.getList();
    this.getDicts("s_job_type").then(response => {
      this.jobTypeOptions = response.data;
    });
    this.getDicts("s_salary_type").then(response => {
      this.salaryTypeOptions = response.data;
    });
    this.getDicts("s_education").then(response => {
      this.educationOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isDisabledAcceptedOptions = response.data;
    });
    this.getDicts("s_is_public").then(response => {
      this.isPublicOptions = response.data;
    });
    this.getAllCompanysInfo()
    this.getAllProvince()
  },
  methods: {
    /** 查询省区域变动触发 */
    queryhandlePChange(){
      this.queryParams.cityId=''
      this.queryParams.countyId=''
      if(this.queryParams.provinceId){
        this.getPChildArea(this.queryParams.provinceId,1)
      }else{
        this.querycityOptions=[]
        this.querycountyOptions=[]
      }
    },
    /** 查询市区域变动触发 */
    queryhandleCityChange(){
      this.queryParams.countyId=''
      if(this.queryParams.cityId){
        this.getCityChildArea(this.queryParams.cityId,1)
      }else{
        this.querycountyOptions=[]
      }
    },
    /** 省区域变动触发 */
    handlePChange(){
      this.form.cityId=''
      this.form.countyId=''
      if(this.form.provinceId){
        this.getPChildArea(this.form.provinceId)
      }else{
        this.cityOptions=[]
        this.countyOptions=[]
      }
    },
    /** 市区域变动触发 */
    handleCityChange(){
      this.form.countyId=''
      if(this.form.cityId){
        this.getCityChildArea(this.form.cityId)
      }else{
        this.countyOptions=[]
      }
    },
    /** 获取省区域列表 */
    getAllProvince(){
      provinceList().then(response => {
        this.provinceOptions = response.data
        if(response.data.length == 0 ){
          console.log("数组大小为0")
        }
      });
    },
    /** 获取子区域列表 */
    getPChildArea(pCode,type){
      cityList(pCode).then(response => {
        if(type){
          this.querycityOptions = response.data
        }else{
          this.cityOptions = response.data
        }
        if(response.data.length == 0 ){
          console.log("数组大小为0")
        }
      });
    },
    getCityChildArea(pCode,type){
      cityList(pCode).then(response => {
        if(type){
          this.querycountyOptions = response.data
        }else{
          this.countyOptions = response.data
        }
        if(response.data.length == 0 ){
          console.log("数组大小为0")
        }
      });
    },
    /** 获取公司列表 */
    getAllCompanysInfo(){
      getAllCompanysInfo().then(response => {
        this.companyOptions = response.data
        if(response.data.length == 0 ){
          console.log("数组大小为0")
        }
      });
    },
    /** 查询企业岗位信息列表 */
    getList() {
      this.loading = true;
      listPosition(this.queryParams).then(response => {
        this.positionList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 岗位类别字典翻译
    jobTypeFormat(row, column) {
      return this.selectDictLabel(this.jobTypeOptions, row.jobType);
    },
    // 薪资类型字典翻译
    salaryTypeFormat(row, column) {
      return this.selectDictLabel(this.salaryTypeOptions, row.salaryType);
    },
    // 学历要求字典翻译
    educationFormat(row, column) {
      return this.selectDictLabel(this.educationOptions, row.education);
    },
    // 是否招聘残疾人字典翻译
    isDisabledAcceptedFormat(row, column) {
      return this.selectDictLabel(this.isDisabledAcceptedOptions, row.isDisabledAccepted);
    },
    // 岗位是否公开字典翻译
    isPublicFormat(row, column) {
      return this.selectDictLabel(this.isPublicOptions, row.isPublic);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        jobId: null,
        companyId: null,
        jobName: null,
        jobType: null,
        jobCnt: null,
        salaryMin: null,
        salaryMax: null,
        salaryType: null,
        education: null,
        isDisabledAccepted: null,
        provinceId: null,
        cityId: null,
        countyId: null,
        workingAddress: null,
        contact: null,
        contactPhoneNo: null,
        isPublic: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        jobDesc: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.jobId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    resetDtls() {
      this.jobDtls = {}
    },
     /** 查看详情 */
    handleDetails(row) {
      this.resetDtls();
      this.jobDtls = JSON.parse(JSON.stringify(row));

      this.jobDtls.jobType = this.selectDictLabel(this.jobTypeOptions, row.jobType);
      this.jobDtls.education = this.selectDictLabel(this.educationOptions, row.education);
      this.jobDtls.isPublic = this.selectDictLabel(this.isPublicOptions, row.isPublic);
      this.jobDtls.isDisabledAccepted = this.selectDictLabel(this.isDisabledAcceptedOptions, row.isDisabledAccepted);

      this.openDtls = true;
      this.titleDtls = "企业岗位详情";
    },
    /** 取消查看详情 */
    cancelDtls() {
      this.openDtls = false;
      this.resetDtls();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加企业岗位信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const jobId = row.jobId || this.ids
      getPosition(jobId).then(response => {
        this.form = response.data;
        this.setCityCounty(this.form)
        this.open = true;
        this.title = "修改企业岗位信息";
      });
    },
    setCityCounty(data){
      if(data.provinceId){
        data.provinceId = parseInt(data.provinceId)
        this.getPChildArea(data.provinceId)
      }
      if(data.cityId){
        data.cityId = parseInt(data.cityId)
        data.countyId = parseInt(data.countyId)
        this.getCityChildArea(data.cityId)
      }
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.jobId != null) {
            updatePosition(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPosition(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const jobIds = row.jobId || this.ids;
      // this.$confirm('是否确认删除企业岗位信息编号为"' + jobIds + '"的数据项?', "警告", {
        this.$confirm('是否确认删除该项数据?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delPosition(jobIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有企业岗位信息数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportPosition(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
<style lang="scss" scoped>
.containerDtls{
  width: 100%;
  height: auto;
  .companyName{
    overflow:hidden; //超出的文本隐藏
    text-overflow:ellipsis; //溢出用省略号显示
    white-space:nowrap; //溢出不换行
  }
  .cel{
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .label{
      width: 120px;
      min-height: 40px;
      font-size: 14px;
      font-weight: bold;
      line-height: 40px;
      text-align: right;
    }
    .value{
      width: calc(100% - 120px);
      min-height: 40px;
      line-height: 40px;
    }

  }
}
</style>